<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类型转换</title>
</head>
<body>
    <script>
        // 字符串类型转换成数值类型
        let a = "99";
        let b = 88;
        console.log(a * 1 + b);
        console.log(Number(a) + b);

        // 数值类型转换成字符串类型
        let c = 99;
        let d = c + '';
        console.log(typeof d);
        let e = String(c);
        console.log(typeof e);

        // 以数字开头的字符串，截取其中的数字
        let f = "77jkhjsahnflk";
        console.log(parseInt(f));
        let g = "77.76jkhjsahnflk";
        console.log(parseFloat(g));

        // 将字符串转换成数组
        let h = "jerhgnjklfdsg";
        console.log(h.split(''));

        // 数组转换为字符串
        let I = ['xia','sn','n'];
        console.log(I.join(''));
        console.log(I.join('*'));



        const J = 'klsdfjklsd';
        console.log(typeof J);//string(会隐式的将它转化为object，从而可以直接使用对应的方法)
        console.log(J.substr(3));

        const K = new String('rujfhjksd');
        console.log(typeof K);//object
        console.log(K.substr(3));


        const arr = ['xiasnn','xiaxia'];
        console.log(arr.toString());

        const num = 768;
        const number = num.toString();
        console.log(typeof number);
        console.log(number + 6567);
    </script>
</body>
</html>